/**************************************************************
  > File Name: 1.c
  > Author: LuoLiang
  > Mail: 1204553475@qq.com 
  > Created Time: 2022年03月06日 星期日 09时51分56秒
 **************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

enum
{
	DATA,
	EOT
};

struct node1
{
	long type;
	int math;
	int English;
};

struct node2
{
	long type;
	char buf[128];
	int math;
	int English;
};

union data
{
	long type;
	struct node1 data1;
	struct node2 data2;
};


int main(int argc, char **argv)
{
	struct node1 data1;
	struct node2 data2;
	union data *data;
	
	data1.type = DATA;
	data1.math = 66;
	data1.English = 77;

	data2.type = EOT;
	data2.math = 88;
	data2.English = 99;
	strcpy(data2.buf, "hello");
	
	data = (union data *)&data2;

	if (data->type == DATA)
	{
		printf("%d\n",data->data1.math);
		printf("%d\n",data->data1.English);
	}

	if (data->type == EOT)
	{
		printf("%d\n",data->data2.math);
		puts(data->data2.buf);
	}
    exit(0);
}
